﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Diagnostics;

namespace Auction_Boxing_2
{
    class Menu
    {
        public int index;
        public int num_entries;

        string[] entries;
        string[] values;

        Vector2[] entry_positions;

        Texture2D background;
        Rectangle bounds;

        public Menu(string[] entries, string[] values, Rectangle bounds, Texture2D background)
        {
            index = 0;
            num_entries = entries.Length;
            this.entries = entries;
            this.values = values;
            this.entry_positions = new Vector2[entries.Length];
            this.background = background;
            //Make background slightly smaller than bounds
            this.bounds = new Rectangle(bounds.X + 10, bounds.Y + 10, bounds.Width - 20, bounds.Height - 20);

            for (int i = 0; i < entries.Length; i++)
            {
                entry_positions[i] = new Vector2(bounds.X + bounds.Width / 12, 
                    bounds.Y + (i + 1) * bounds.Height / (entries.Length + 1));
            }
        }

        public void ChangeValue(string value)
        {
            values[index] = value;
        }

        public void Update()
        {

        }

        public void Draw(SpriteBatch spriteBatch, SpriteFont font)
        {
            spriteBatch.Draw(background, bounds, Color.White * .5f);

            for ( int i = 0; i < entries.Length; i++)
            {
                //Selected string is red
                Color color = Color.Black;

                if (index == i)
                    color = Color.Red;

                spriteBatch.DrawString(font, entries[i] + values[i], entry_positions[i], color);
            }

        }
    }
}
